<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>侦听事件watch指令</title>
</head>
<body>
    <div id="app">
        <p>今天你是否已经完成了签到？</p>
        <p>问答Y/N: <input type="text" v-model="question"></p>
        <p>{{ answer }}</p>
    </div>
</body>
<script src="vue.js"></script>
<script>
    new Vue({
        el: "#app",
        data: {
            question: "",
            answer: "主要是回答YES或NO, 就可以看到答案！"
        },
        // 侦听事件
        watch: {
            question: function() {
                if(this.question == "Y") {
                    return this.answer = "很好，签到成功！";
                } else {
                    return this.answer = "请尽快完成签到！";
                }

            }
        }
    })
</script>
</html>